/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kursova_perzeptron;

/**
 *
 * @author ruslan
 */
import java.util.Arrays;
import java.util.Random;
import org.neuroph.core.*;
import org.neuroph.core.learning.DataSet;
import org.neuroph.core.learning.DataSetRow;
import org.neuroph.core.learning.SupervisedTrainingElement;
import org.neuroph.core.learning.TrainingSet;
import org.neuroph.nnet.*;
import org.neuroph.util.*;

/**
 *
 * @author ruslan
 */
public class NeurophTestApp {

    /**
     * @param args the command line arguments
     */
     NeuralNetwork neuralNetwork;
     DataSet trainingSet;
     double[] networkOutput;
     public void go(String[] args) {
        neuralNetwork= new MultiLayerPerceptron(4, 1);
 
         trainingSet =  new  DataSet(4, 1);

        
        trainingSet.addRow (new DataSetRow (new double[]{18.9, 10, 8.6, 22},
        new double[]{0.2}));
        trainingSet.addRow (new DataSetRow (new double[]{12.6, 15.1, 14.4, 10},
        new double[]{0.25}));
        trainingSet.addRow (new DataSetRow (new double[]{14.1, 7.8, 12.3, 12},
        new double[]{0.3}));
        trainingSet.addRow (new DataSetRow (new double[]{15.0, 9.5, 12.8, 8},
        new double[]{0.36}));
        trainingSet.addRow (new DataSetRow (new double[]{10.7, 22.2, 11.9, 14},
        new double[]{0.31}));
        trainingSet.addRow (new DataSetRow (new double[]{11.5, 17.4, 18.2, 7},
        new double[]{0.401}));
        //покришки
        trainingSet.addRow (new DataSetRow (new double[]{10.9, 15.6, 17.9, 8},
        new double[]{0.78}));
        trainingSet.addRow (new DataSetRow (new double[]{12.6, 40.1, 8.5, 4},
        new double[]{0.9}));
        trainingSet.addRow (new DataSetRow (new double[]{9.5, 27.8, 12.4, 5},
        new double[]{0.8}));
        trainingSet.addRow (new DataSetRow (new double[]{8.8, 18.9, 25.0, 3},
        new double[]{0.812}));


System.out.println("training started...");
neuralNetwork.learn(trainingSet); 
neuralNetwork.save("or_perceptron.nnet"); 

//////////USING

 

// set network input 
System.out.println("set input...");
neuralNetwork.setInput(11.5, 17.4, 18.2, 7); 

// calculate network 
neuralNetwork.calculate(); 

// get network output 
networkOutput = neuralNetwork.getOutput(); 
System.out.println(Arrays.toString(networkOutput));  

     }
    public static void main(String[] args) {

    }
}